package com.vhall.component.controller.tag;

import com.vhall.component.entity.page.vo.PageVO;
import com.vhall.component.entity.tag.vo.AdvertisingListReqVO;
import com.vhall.component.entity.tag.vo.AdvertisingListRspVO;
import com.vhall.component.entity.tag.vo.AdvertisingReqVO;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.enums.OperateTypeEnum;
import com.vhall.component.service.annotation.OperateLog;
import com.vhall.component.service.tag.AdvertisingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 广告管理
 *
 * @author shimingming
 * @since 2023/4/11 19:06
 */
@Slf4j
@RestController
@RequestMapping("/v4/admin/advertising")
public class AdvertisingController {

    @Resource
    AdvertisingService advertisingService;


    /**
     * 保存
     */
    @TokenAuth
    @PostMapping("/add")
    @OperateLog(module = "广告管理", type = OperateTypeEnum.CREATE, name = "保存")
    public Boolean add(@Validated AdvertisingReqVO vo) {
        return advertisingService.add(vo);
    }

    /**
     * 更新
     */
    @TokenAuth
    @PostMapping("/update")
    @OperateLog(module = "广告管理", type = OperateTypeEnum.UPDATE, name = "更新")
    public Boolean update(@Validated AdvertisingReqVO vo) {
        return advertisingService.updateInfo(vo);
    }


    /**
     * 列表分页
     */
    @TokenAuth
    @PostMapping("/list")
    public PageVO<AdvertisingListRspVO> list(AdvertisingListReqVO vo) {
        return advertisingService.list(vo);
    }

    /**
     * 根据id 查询信息
     */
    @TokenAuth
    @GetMapping("/info")
    public List<AdvertisingListRspVO> info(@RequestParam("ids") List<Integer> ids) {
        return advertisingService.getInfo(ids);
    }
}
